package com.starsea.book.ui.newpage.pop

import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ToastUtils
import com.lxj.xpopup.core.CenterPopupView
import com.starsea.book.R
import com.starsea.book.ui.newpage.adapter.NewUserAdapter
import com.starsea.book.ui.newpage.entity.Today
import com.starsea.book.ui.newpage.normalview.RadiusTextView

/**
 * @author Lee
 * @createTime 2023-08-04 16 GMT+8
 * @desc : 补签
 */
class NewUserPop(
    var mContext: Context,
    var startDate: String,
    var endDate: String,
    var sign: Boolean,
    var data: MutableList<Today>,
    var onResult: ((today: Int) -> Unit)? = null
) :
    CenterPopupView(mContext) {

    lateinit var iv_close: ImageView
    lateinit var tv_title_desc: TextView
    lateinit var rv_content: RecyclerView
    lateinit var tv_confim: TextView
    lateinit var rtv_sign_hint: RadiusTextView

    lateinit var mAdapter: NewUserAdapter

    override fun getImplLayoutId(): Int {
        return R.layout.layout_new_user_pop
    }

    override fun onCreate() {
        super.onCreate()
        rv_content = findViewById(R.id.rv_content)
        mAdapter = NewUserAdapter(mContext)
        rv_content.layoutManager = GridLayoutManager(mContext, 4)
        rv_content.adapter = mAdapter
        mAdapter.setItems(data)


        iv_close = findViewById(R.id.iv_close)
        tv_title_desc = findViewById(R.id.tv_title_desc)

        tv_title_desc.text = "${startDate}-${endDate}每天登录可领取"


        tv_confim = findViewById(R.id.tv_confim)

        rtv_sign_hint = findViewById(R.id.rtv_sign_hint)

        iv_close.setOnClickListener {
            dismiss()
        }
        tv_confim.setOnClickListener {
            if (sign) {
                ToastUtils.showShort("今日已领取")
            } else {
                onResult!!.invoke(1)
            }


            dismiss()
        }
        rtv_sign_hint.setOnClickListener {

        }

    }


}